const koa=require('koa');
const session=require('koa-session');

let server=new koa();
server.listen(8080);

server.use(session({
	maxAge:20*60*1000
},server));//吧server也传进去
server.keys=['adsfasdf','asdfwqrwer']//秘钥

server.use(async ctx=>{
	let n;
	
	if(ctx.session[n]){
		ctx.session[n]++;
	}else{
		ctx.session[n]=1;
	};
	console.log(`你是第${ctx.session[n]}次访问`);
	ctx.response.body=`你是第${ctx.session[n]}次访问`;//默认一天以后消失

})
